#!/usr/bin/python
# -*- coding: utf-8 -*-



import time


from pyfirmata import Arduino, util
print "wait..."
board = Arduino('/dev/ttyUSB0',baudrate=9600)
print "arduino connected"

board.servo_config(9, min_pulse=544, max_pulse=2400, angle=0)
board.servo_config(11, min_pulse=544, max_pulse=2400, angle=0)


def change(servoId,angel,timeout=1/10):
    board.digital[servoId].write(angel)
    time.sleep(timeout)


def changeservos(angle=180,revers=False,servos=(9,11)):
    if revers:
        for ang in reversed(range(angle)):
            for sid in servos:
                change(sid, ang)
    else:
        for ang in range(angle):
            for sid in servos:
                change(sid, ang)


servos=(9,11)
changeservos(180,False,servos)
changeservos(180,True,servos)



